package IOStream.IOBuffered;

import java.io.*;

/**
 * ClassName:BufferedStream002
 * Package:IOStream.IOBuffered
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/3/2-19:44
 * @Version:v1.0
 */
public class BufferedStream002 {
    /**字节缓冲流---高级流
     *                 字节缓冲流
     * BufferedInputStream   BufferedOutputStream
     *    字节缓冲输入流            字节缓冲输出流
     *
     * public BufferedInputStream(InputStream is)   把基本流包装成高级流,提高读取数据的性能
     * public BufferedOutputStream(OutputStream os) 把基本流包装成高级流,提高写出数据的性能
     *
     * 原理：底层自带了长度为8192的缓冲区提高性能 */
    public static void main(String[] args) throws IOException {
        //创建缓冲流对象
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\aaa\\a.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("E:\\aaa\\g.txt"));
        //拷贝(一次读写多个字节)
        byte[]bytes = new byte[1024];
        int b;
        while ((b=bis.read(bytes))!=-1){
            bos.write(bytes,0,b);
        }
        //释放资源
        bos.close();
        bis.close();
    }
}
